package com.zlq.cn.service.ai;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zlq.cn.bootstrap.SignApiBootstrap;
import com.zlq.cn.entity.AizhPicture;
import com.zlq.cn.entity.FanyiUser;
import com.zlq.cn.mapper.ai.AizhPictureMapper;
import com.zlq.cn.service.un.FanyiUserService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 * AI作画 服务实现类
 * </p>
 *
 * @author zhoucl
 * @since 2022-11-29
 */
@Service
public class AizhPictureService extends ServiceImpl<AizhPictureMapper, AizhPicture> {
    @Resource
    private FanyiUserService fanyiUserService;

    @Override
    public boolean save(AizhPicture entity) {
        FanyiUser fanyiUser = fanyiUserService.getById(SignApiBootstrap.get().getImei());
        Assert.notNull(fanyiUser, "用户不存在");
        entity.setUserId(fanyiUser.getFanyiUserImei());
        entity.setCreateTime(LocalDateTime.now());
        return super.save(entity);
    }
}
